<?php

/**
 * @author shuang
 * @date 2016-10-26 13:44:48
 */
use common\components\MTools;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;

$this->title = "";
$this->registerCssFile("/js/ui-dialog.css");
$this->registerJsFile("/js/dialog-min.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJsFile("/js/upgrade.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJs('$.upgrade.init({upgradeurl:"' . Url::toRoute(["upgrade"]) . '"});$.upgrade.btnUpgrade()');
echo $this->render("//layouts/breadcrumb", ["url" => Url::toRoute(["grade/level"]), "title" => "代理升级"]);
?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12 well  ibox float-e-margins">
            <div class="ibox-title">代理升级充值<span class="pull-right">当前级别：<?php echo \frontendm\models\WB_Grade::findOne(ArrayHelper::getValue($res, "userprofile.gradeid"))->name;?></span></div>
            <div class="well-content ibox-content">
                <div class="clearfix"></div>
                <div class="table-responsive">
                    <div id="table1_wrapper" class="dataTables_wrapper no-footer">
                        <table id="table1" class="table dataTable no-footer" >
                            <thead>
                                <tr>
                                    <th style="width: 20%">代理级别</th>
                                    <th style="width: 20%">需要充值预付款金额(元)</th>
                                    <th style="width: 20%">购买升级价格</th>
                                    <?php if (ArrayHelper::getValue($res, "amount") > MTools::getYiiParams("upgrade_amount")): ?>
                                        <th style="width: 25%">升级</th>
                                    <?php endif; ?>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($data as $item): ?>
                                    <tr>
                                        <td><?php echo $item["name"]; ?></td>
                                        <td><?php echo $item["advance_payment"]; ?></td>
                                        <td style="text-align: center;"><?php echo $item["upgrade_price"]; ?></td>
                                        <?php if (ArrayHelper::getValue($res, "amount") > MTools::getYiiParams("upgrade_amount")): ?>
                                            <td class="center">
                                                <?php if (Yii::$app->user->identity->gradeid < $item["id"]): ?>
                                                    <a href="javascript:;" class="btn btn-success shengji" data-id="<?php echo $item["id"]; ?>">升级</a>
                                                <?php endif; ?>
                                            </td>
                                        <?php endif; ?>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                        <?php echo MTools::getTemplate("level-list-notice.html");?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>